﻿using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using UnityEngine;

public class Lesson4T
{
    public int num;
    public SerializableDictionary<int, string> dic;
}

public class TestDictionary : MonoBehaviour
{
    
    void Start()
    {
        string path = Application.persistentDataPath + "/TestDic.xml";
        print(Application.persistentDataPath);
        Lesson4T dicTest = new Lesson4T();
        dicTest.num = 114;
        dicTest.dic = new SerializableDictionary<int, string>();
        dicTest.dic.Add(5, "20");
        dicTest.dic.Add(6, "98");
        dicTest.dic.Add(8, "86");


        using (StreamWriter sw = new StreamWriter(path))
        { 
            XmlSerializer xs = new XmlSerializer(typeof(Lesson4T));
            xs.Serialize(sw, dicTest);
        }


        Lesson4T dicTest2 = new Lesson4T();
        using (StreamReader sr = new StreamReader(path))
        {
            XmlSerializer xs = new XmlSerializer(typeof(Lesson4T));
            dicTest2 = xs.Deserialize(sr) as Lesson4T;
        }
    }


}
